package com.aiyige.page.mediaslider;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.aiyige.R;
import com.aiyige.arouter.config.ARouterConfig;
import com.aiyige.page.mediaslider.adapter.MediaSliderAdapter;
import com.aiyige.page.mediaslider.model.Media;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;

import java.util.LinkedList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

@Route(path = ARouterConfig.MediaSliderPage)
public class MediaSliderPage extends AppCompatActivity {
    @Autowired
    List<Media> mediaList = new LinkedList<>();
    @BindView(R.id.mediaSliderVp)
    MediaSliderViewPager mediaSliderVp;
    MediaSliderAdapter mediaSliderAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.page_activity_media_slider);
        ButterKnife.bind(this);
        ARouter.getInstance().inject(this);
        mediaSliderAdapter = new MediaSliderAdapter(getSupportFragmentManager(), mediaList);
        mediaSliderVp.setAdapter(mediaSliderAdapter);
        mediaSliderVp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                mediaSliderAdapter.currentSelectedIndex(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }
}
